package com.xlb.web.service.impl;

import com.xlb.domain.dos.NoticeDO;
import com.xlb.domain.mapper.NoticeMapper;
import com.xlb.utils.Response;
import com.xlb.web.model.vo.notice.FindNoticeInfoRspVO;
import com.xlb.web.service.NoticeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * @author 小聋包
 * @date 2024/9/21
 * @Version 1.0
 */
@Service
@Slf4j
public class NoticeServiceImpl implements NoticeService {

    @Autowired
    private NoticeMapper noticeMapper;

    @Override
    public Response findNoticeInfo() {
        NoticeDO noticeDO = noticeMapper.selectShow();

        if (Objects.nonNull(noticeDO)) {
            return Response.success(FindNoticeInfoRspVO.builder()
                    .content(noticeDO.getContent())
                    .build());
        }

        return Response.success();
    }
}

